<%@ page language="java" contentType="text/html; charset=UTF-8" %>
<%@ include file="/jsplib/pubhead.jsp"%>
<%@ page import="net.comm.common.ValueMaping" %>
<%@ taglib uri="/WEB-INF/myTaglib.tld" prefix="tag"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<title>部落活动</title>
	<link href="${cpath}/css/youlin.css" rel="stylesheet" type="text/css" media="all" />
	<script type="text/javascript" src="${cpath}/fckeditor/fckeditor.js"></script>
	<SCRIPT src="${cpath}/js/glk_array.js" type=text/javascript></SCRIPT>
	<SCRIPT src="${cpath}/js/glr_array.js" type=text/javascript></SCRIPT>
	<SCRIPT src="${cpath}/js/glfun.js"	   type=text/javascript></SCRIPT>
</head>
<body>
<!--外套 start -->
<div class="wrap">
  <!--页首 start -->
	<%@ include file="/menu.jsp"%>
  <!--页首 end -->  
  
  <!--导航面包屑 start -->
  <div class="breadCrumb">
  <div class="breadCrumbNav">当前位置：<a href="${cpath}/users.do?action=main">我的主页</a>  >> <a href="${cpath}/group_get/groupID_${theForm.groupID}.html">部落</a></div>
	<%@ include file="/navf.jsp"%> 
 </div> 
  <!--导航面包屑 end -->
  
  <!--主体 start -->
 <div class="body">
 
  <div class="hotBox1">  
    <div class="hotBox1-left">
	<c:if test="${theForm.groupID != 99999999}">
      <a href="${cpath}/qunzu_${theForm.groupID}"><img src="${cpath}/${myfn:getGroupPic(theForm.groupID)}"  width="75" height="75"  class="shequ icon user_icon_2"></a>
      <p class="nav"><a href="${cpath}/group_get/groupID_${theForm.groupID}.html">${myfn:getGroupName(theForm.groupID)}</a>&nbsp;&gt;&nbsp;<a href="${cpath}/gparty_adlist/qryGroupID_${theForm.groupID}.html">活动区</a></p>
	</c:if>
	<c:if test="${theForm.groupID == 99999999}">
      <a href="${cpath}/shequ_home/villageID_${theForm.villageID}.html"><img src="${cpath}/images/fm.jpg" width="102" height="75" ></a>
      <p class="nav"><a href="${cpath}/shequ_home/villageID_${theForm.villageID}.html">${myfn:getVillageName(theForm.villageID)}</a>&nbsp;&gt;&nbsp;<a >社区资料</a></p>
	</c:if>
    </div>
    <div class="hotBox1-right">
      <p><a href="javascript:history.go(-1);"><img src="${cpath}/images/icon_32.gif" width="137" height="25" /></a></p>
      <p>&nbsp;</p>    
    </div>
  </div> 
  
 <div class="left-Box6">
	<h3 class="nav"><a >部落活动</a></h3>

  <div class="left-Box6-content">
   <div class="left-Box6-content-inner">   
	<form action="${cpath}/gparty.do" name="theForm"  method="post" enctype="multipart/form-data" class="frmAddTopic" >
		<p><label>标&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;题:</label>
			<input type="text" name='title' value='${theForm.title}' maxlength="100" class="long"/></p>
		<p><label>类&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;型:</label>			
			<select id='firsort' name='firsort'>
			<option value="0">请选择</option>
			<option value="1">亲子</option>
			<option value="2">教育</option>
			<option value="3">游戏</option>
			<option value="4">美食</option>
			<option value="5">旅游</option>
			<option value="6">运动</option>
			<option value="7">公益</option>
			<option value="8">娱乐</option>
			<option value="9">欣赏</option>
			<option value="10">其他</option>
			</select>
			</p>
		<p><label>活动介绍:</label>
			<textarea name="fck" rows="8" cols="40" >${theForm.info}</textarea></p>
		<p><label>海&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;报:</label>
			<input type="file" name='filepath' value='' class="long"/></p>
		<p><label>起止时间:</label>
			<input type="text" name='bgtime' value='${myfn:formatDate14(theForm.bgtime,"-")}' class="short" readonly=true onClick="setDayHM(this);"/>－<input type="text" name='endtime' value='${myfn:formatDate14(theForm.endtime,"-")}'  class="short" readonly=true onClick="setDayHM(this);"/></p>
		<p><label>报名截止:</label>
			<input type="text" name='signEtime' value='${myfn:formatDate14(theForm.signEtime,"-")}' class="short" readonly=true onClick="setDayHM(this);"/></p>
		<p><label>活动城市:</label>
			<tag:CNPCA name="work_location" id="work_location" pid="0" cid="0" value='${theForm.work_location}'   onchange="getAjaxdata('cnpid',this.value)" onkeydown="catch_keydown(this);"/>
			<span id=cnpid style="display:inline">
			<tag:CNPCA name="work_sublocation" pid="${theForm.work_location}" cid="0" value='${theForm.work_sublocation}' onkeydown="catch_keydown(this);"/>
			</span>					
			</p>
		<p><label>活动地址:</label>
			<input type="text" name='place' value='${theForm.place}' maxlength="150" class="long"/></p>
		<p><label>联系方式:</label>
			<input type="text" name='tel' value='${theForm.tel}' maxlength="150" class="short"/></p>
		<p><label>活动费用:</label>
			<input type="text" name='charge' value='${theForm.charge}' maxlength="50" class="short"/></p>
		<p><label>计划人数:</label>
			<input type="text" name='planNum' value='${theForm.planNum}' maxlength="5" class="short"/></p>

       <p class="btn">
       <a href="javascript:doConfirm();"><img src="${cpath}/images/icon_09.gif" /></a> 
       <a href="javascript:history.go(-1);"><img src="${cpath}/images/icon_33.gif" /></a>
       </p>
		<!--隐藏域-->
		<input type="hidden" name='userID'		value='${theForm.userID}'/>
		<input type="hidden" name='groupID'		value='${theForm.groupID}'/>
		<input type="hidden" name='secsort'		value='${theForm.secsort}'/>
		<input type="hidden" name='thisort'		value='${theForm.thisort}'/>
		<input type="hidden" name='info'		value='${theForm.info}'/>
		<input type="hidden" name='smallPic'	value='${theForm.smallPic}'/>
		<input type="hidden" name='status'		value='${theForm.status}'/>
		<input type="hidden" name='attach'		value='${theForm.attach}'/>
		<input type="hidden" name='ctime'		value='${theForm.ctime}'/>
		<input type="hidden" name='signNum'		value='${theForm.signNum}'/>
		<input type="hidden" name='action'		value='${theForm.action}'/>     
     </form>
      </div>
   <div class="clearFloat"></div>
  </div>
</div>
  
    <div class="clearFloat"></div>
 </div> 
 <!--主体 end -->
 
 <!--页脚 start -->
	<%@ include file="/foot.jsp"%>
 <!--页脚 end --> 
</div>
<!--外套 end -->

</body>
</html>
<!---->
<script type="text/javascript">
  var oFCKeditor = new FCKeditor('fck');	//传入参数为表单元素（由FCKeditor生成的input或textarea）的name
      oFCKeditor.BasePath='${cpath}/fckeditor/';//指定FCKeditor根路径，也就是fckeditor.js所在的路径
      oFCKeditor.Height='230px';
      oFCKeditor.Width='650px';
      oFCKeditor.ToolbarSet='Demo';				//指定工具栏
	  oFCKeditor.ReplaceTextarea();
</script>
<!-- 日历显示 -->
<script src="${cpath}/js/calendar.js"></script>
<script >setDateSplit("-");</script>

<script>
    /**
     * 检查项目资料维护
     */
	function doConfirm()
	{
		var form = document.theForm;

		var action = form['action'];

		var groupID = form['groupID'];

		var title = form['title'];
		var info = form['info'];
		var fck = FCKeditorAPI.GetInstance("fck").GetXHTML("true");   

		if(title.value == null||title.value.replace(/(^\s*)|(\s*$)/g,"").length < 1)
  		{
			alert('标题不能为空');
			title.select();
			return ;
		}
		var firsort = form['firsort'];
		if(firsort.value == "")
  		{
			alert('请选择活动类型');
			firsort.select();
			return ;
		}
		var bgtime = form['bgtime'];
		if(bgtime.value == "")
  		{
			alert('请选择活动开始时间');
			bgtime.select();
			return ;
		}
		var endtime = form['endtime'];
		if(endtime.value == "")
  		{
			alert('请选择活动结束时间');
			endtime.select();
			return ;
		}

		var work_sublocation = form['work_sublocation'];
		if(work_sublocation == null || work_sublocation.value == ""|| work_sublocation.value == "0")
  		{
			alert('请选择活动城市');
			return ;
		}
		var place = form['place'];
		if(place.value == null||place.value.replace(/(^\s*)|(\s*$)/g,"").length < 1)
  		{
			alert('请输入活动地址');
			place.select();
			return ;
		}
		var tel = form['tel'];
		if(tel.value == null||tel.value.replace(/(^\s*)|(\s*$)/g,"").length < 1)
  		{
			alert('请输入联系方式');
			tel.select();
			return ;
		}
		var signEtime = form['signEtime'];
		if(signEtime.value == null||signEtime.value.replace(/(^\s*)|(\s*$)/g,"").length < 1)
  		{
			alert('请输入报名截止时间');
			signEtime.select();
			return ;
		}

		var charge = form['charge'];
		if(charge.value == null||charge.value.replace(/(^\s*)|(\s*$)/g,"").length < 1)
  		{
			alert('请输入活动费用');
			charge.select();
			return ;
		}
		var planNum = form['planNum'];
		if(planNum.value == null||planNum.value.replace(/(^\s*)|(\s*$)/g,"").length < 1)
  		{
			alert('请输入计划活动人数');
			planNum.select();
			return ;
		}
		
		info.value = gjcfilter(fck);
		if(info.length > 30000)
		{
			alert('活动介绍长度不能大于30000,当前长度：' + info.length);
			return ;
		}
		form.submit();
	}
	function my_getbyid(id)
	{

		 itm = null;
		 if (document.getElementById)
		 {
				itm = document.getElementById(id);
		 }
		 else if (document.all)
		 {
				itm = document.all[id];
		 }
		 else if (document.layers)
		 {
				itm = document.layers[id];
		 }		 
		 return itm;
	}

	function getAjaxdata(div,id)
	{

		var xmlHttp;
		start = true;
		try
		{    // Firefox, Opera 8.0+, Safari    
			xmlHttp=new XMLHttpRequest();
		}
		catch (e)
		{    // Internet Explorer    
			try
			{
				xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
			}
			catch (e)
			{
				try
				{
					xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
				}
				catch (e)
				{
					alert("Your browser does not support AJAX!");
					return false;
				}
			}
		}
		var url;
		if(div =="divsecsort"){

			url = "${cpath}/param/getproperty.jsp?assortID=2&parentID=" + id ;

		}else if(div =="cnpid" ){
		
			url = "${cpath}/param/getCnpid.jsp?pid=" + id ;
//			my_getbyid("cncid").innerHTML="<select name='work_Area' onkeydown='catch_keydown(this);'></select>";
		}else if(div =="homepid" ){
		
			url = "${cpath}/param/getCnpid.jsp?pid=" + id ;
			my_getbyid("homecid").innerHTML="<select name='home_Area' onkeydown='catch_keydown(this);'></select>";
		}else {

			url = "${cpath}/param/getCncid.jsp?cid=" + id;
		}
		if (start)
		{
			my_getbyid(div).innerHTML='后台取数据……';
			xmlHttp.onreadystatechange=function()
			{
				if(xmlHttp.readyState==4 && xmlHttp.status==200)
				{
					var ret_str = xmlHttp.responseText;
					if(div =="divsecsort"){
						var secsort = "<select name='secsort' onkeydown='catch_keydown(this);'>" +
							ret_str.replace(/(^\s*)|(\s*$)/g,"") + "</select>"
						my_getbyid(div).innerHTML = secsort;

					}else if(div =="cnpid"){

						var secsort = "<select name='work_sublocation' onkeydown='catch_keydown(this);'" +
							" >" + 
							ret_str.replace(/(^\s*)|(\s*$)/g,"") + "</select>"
						my_getbyid(div).innerHTML = secsort;

					}else if(div =="homepid"){

						var secsort = "<select name='home_sublocation' onkeydown='catch_keydown(this);'" +
							" onChange=\"getAjaxdata('homecid',this.value)\">" + 
							ret_str.replace(/(^\s*)|(\s*$)/g,"") + "</select>"
						my_getbyid(div).innerHTML = secsort;

					}else if(div =="homecid"){

						var secsort = "<select name='home_area' id='home_area' onkeydown='catch_keydown(this);'>" +
							ret_str.replace(/(^\s*)|(\s*$)/g,"") + "</select>"
						my_getbyid(div).innerHTML = secsort;

					}else{
						var secsort = "<select name='work_area' id='work_area' onkeydown='catch_keydown(this);' onchange=\"getVillage('villagediv',this.value)\">" +
							ret_str.replace(/(^\s*)|(\s*$)/g,"") + "</select>"
						my_getbyid(div).innerHTML = secsort;
					}
				}
			}
			xmlHttp.open("GET",url,true);
			xmlHttp.send(null);
		}
	}
  /**
   * 根据具体请求设置各个组件状态	
   */
  function showState()
  {
		var action = '${theForm.action}';
		var form = document.theForm;		
		if(action == 'detail')
		{
           
			document.getElementById("back").style.display = "none";
		}
		else if(action == 'modifyPage' || action == 'update')
		{

			form['action'].value = 'update';
		}else{

			form['action'].value = 'add';
		}

	}
	showState();

</script>